using FireStarter.Base;
using NUnit.Framework;

namespace Firestarter.DB_DomainModel.Logic.Test
{
    [TestFixture]
    public class TestStringUtilsDB : TestBase
    {
        [SetUp]
        public override void SetupTest()
        {
            //Runs every time that any testmethod is executed
            base.SetupTest();
        }

        [TearDown]
        public override void TearDownTest()
        {
            //runs every time any testmethod is complete
            base.TearDownTest();
        }

        [Test]
        public void Test_DelimitPascalCase_NoSeperators()
        {
            //---------------Set up test pack-------------------
            const string tableName = "TableName";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string pascalCase = StringUtilities.PascalCaseTableName(tableName);
            //---------------Test Result -----------------------
            Assert.AreEqual(tableName, pascalCase);
        }
        [Test]
        public void Test_DelimitPascalCase_Seperator_()
        {
            //---------------Set up test pack-------------------
            const string tableName = "Table_Name";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string pascalCase = StringUtilities.PascalCaseTableName(tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "TableName";
            Assert.AreEqual(expectedTableName, pascalCase);
        }
        [Test]
        public void Test_DelimitPascalCase_Seperator_NextLetterLowerCase()
        {
            //---------------Set up test pack-------------------
            const string tableName = "Table_name";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string pascalCase = StringUtilities.PascalCaseTableName(tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "TableName";
            Assert.AreEqual(expectedTableName, pascalCase);
        }
        [Test]
        public void Test_DelimitPascalCase_Seperator_FirstLetterLowerCase()
        {
            //---------------Set up test pack-------------------
            const string tableName = "table_name";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string pascalCase = StringUtilities.PascalCaseTableName(tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "TableName";
            Assert.AreEqual(expectedTableName, pascalCase);
        }
        [Test]
        public void Test_DelimitPascalCase_DashSeperator_FirstLetterLowerCase()
        {
            //---------------Set up test pack-------------------
            const string tableName = "table-name";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string pascalCase = StringUtilities.PascalCaseTableName(tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "TableName";
            Assert.AreEqual(expectedTableName, pascalCase);
        }
        [Test]
        public void Test_DelimitPascalCase_TwoDashSeperator_FirstLetterLowerCase()
        {
            //---------------Set up test pack-------------------
            const string tableName = "table-name_full";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string pascalCase = StringUtilities.PascalCaseTableName(tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "TableNameFull";
            Assert.AreEqual(expectedTableName, pascalCase);
        }
        [Test]
        public void Test_DelimitPascalCase_TwoDashSeperator()
        {
            //---------------Set up test pack-------------------
            const string tableName = "table-_name";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string pascalCase = StringUtilities.PascalCaseTableName(tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "TableName";
            Assert.AreEqual(expectedTableName, pascalCase);
        }
        [Test]
        public void Test_DelimitPascalCase_SpaceSeperator_FirstLetterLowerCase()
        {
            //---------------Set up test pack-------------------
            const string tableName = "table name";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string pascalCase = StringUtilities.PascalCaseTableName(tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "TableName";
            Assert.AreEqual(expectedTableName, pascalCase);
        }
        [Test]
        public void Test_DelimitPascalCase_TwoSpaceSeperator_FirstLetterLowerCase()
        {
            //---------------Set up test pack-------------------
            const string tableName = "table  name";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string pascalCase = StringUtilities.PascalCaseTableName(tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "TableName";
            Assert.AreEqual(expectedTableName, pascalCase);
        }
        [Test]
        public void Test_DelimitPascalCase_OneChar()
        {
            //---------------Set up test pack-------------------
            const string tableName = "t";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string pascalCase = StringUtilities.PascalCaseTableName(tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "T";
            Assert.AreEqual(expectedTableName, pascalCase);
        }

        [Test]
        public void Test_Singularise()
        {
            //---------------Set up test pack-------------------
            const string tableName = "tables";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string pascalCase = StringUtilities.Singularize(tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "table";
            Assert.AreEqual(expectedTableName, pascalCase);
        }

        [Test]
        public void Test_RemovePrefix()
        {
            //---------------Set up test pack-------------------
            const string tableName = "tbtable";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            string updatedTableName = StringUtilities.RemovePrefix("tb", tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "table";
            Assert.AreEqual(expectedTableName, updatedTableName);
        }

        [Test]
        public void Test_RemoveTableNamePrefix_TableDoesNotHaveAPrefix()
        {
            //---------------Set up test pack-------------------
            const string tableName = "TableName";
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string updatedTableName = StringUtilities.RemovePrefix("tbl", tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "TableName";
            Assert.AreEqual(expectedTableName, updatedTableName);
        }
        
        [Test]
        public void Test_RemoveTableNamePrefix_TableHasAPrefix_UpperCase()
        {
            //---------------Set up test pack-------------------
            const string tableName = "TBLTableName";
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string updatedTableName = StringUtilities.RemovePrefix("tbl", tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "TableName";
            Assert.AreEqual(expectedTableName, updatedTableName);
        }

        [Test]
        public void Test_RemoveTableNamePrefix_TableHasAPrefix_AndHasPrefixValueAtEnd()
        {
            //---------------Set up test pack-------------------
            const string tableName = "tblTableNametbl";
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string updatedTableName = StringUtilities.RemovePrefix("tbl", tableName);
            //---------------Test Result -----------------------
            const string expectedTableName = "TableNametbl";
            Assert.AreEqual(expectedTableName, updatedTableName);
        }
       
        [Test]
        public void Test_IsManyPascalWords_NoCaps()
        {
            //---------------Set up test pack-------------------
            const string tableName = "table";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            bool pascalCase = StringUtilities.IsManyPascalWords(tableName);
            //---------------Test Result -----------------------
            Assert.IsFalse(pascalCase);
        }
        [Test]
        public void Test_IsManyPascalWords_FirstLetterCapital()
        {
            //---------------Set up test pack-------------------
            const string tableName = "Table";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            bool pascalCase = StringUtilities.IsManyPascalWords(tableName);
            //---------------Test Result -----------------------
            Assert.IsFalse(pascalCase, "Should not show as a pascal cased word since only first letter is capital");
        }
        [Test]
        public void Test_IsManyPascalWords_FirstLetterNotCapital_OtherLettersCapital()
        {
            //---------------Set up test pack-------------------
            const string tableName = "tableName";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            bool pascalCase = StringUtilities.IsManyPascalWords(tableName);
            //---------------Test Result -----------------------
            Assert.IsFalse(pascalCase, "Should not show as a pascal cased word since first letter is not capital");
        }
        [Test]
        public void Test_IsManyPascalWords_FirstLetterCapital_OtherLettersCapital()
        {
            //---------------Set up test pack-------------------
            const string tableName = "TableName";
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            bool pascalCase = StringUtilities.IsManyPascalWords(tableName);
            //---------------Test Result -----------------------
            Assert.IsTrue(pascalCase, "Should show as a pascal cased word since first letter is capital");
        }
    }
}